#!/usr/bin/python
# coding=utf-8
# author=He


import time
import datetime
import calendar


# 今天日期
today = datetime.date.today()

# 本月天数
day_num = calendar.monthrange(today.year, today.month)[1]

# 上月是几月
month_is_num = (today.month - 6) == 0 and 12 or today.month-1

# 上月是那一年
month_is_year = (today.month - 6) == 0 and today.year-1

# 上月天数
upper_month_day_num = calendar.monthrange((today.month - 6) == 0 and today.year-1 or today.year, (today.month - 6) == 0
                                          and 12 or today.month-1)[1]

# 昨天时间
yesterday = today - datetime.timedelta(days=1)

# 明天时间
tomorrow = today + datetime.timedelta(days=1)
acquire = today + datetime.timedelta(days=2)

# 月初日期
month_start_date = today - datetime.timedelta(days=(today.day < 1) and 1 or today.day-1)

# 月初日期
month_end_date = today + datetime.timedelta(days=day_num-today.day)

# 下月月初日期
month_under_date = today + datetime.timedelta(days=(day_num-today.day)+1)

# 上月开始日期
upper_month_start_date = today - datetime.timedelta(days=(upper_month_day_num+(today.day-1)))

# 上月结束日期
upper_month_end_date = today - datetime.timedelta(days=today.day)

# 昨天开始时间戳
yesterday_start_time = int(time.mktime(time.strptime(str(yesterday), '%Y-%m-%d')))

# 昨天结束时间戳
yesterday_end_time = int(time.mktime(time.strptime(str(today), '%Y-%m-%d'))) - 1

# 今天开始时间戳
today_start_time = yesterday_end_time + 1

# 今天结束时间戳
today_end_time = int(time.mktime(time.strptime(str(tomorrow), '%Y-%m-%d'))) - 1

# 明天开始时间戳
tomorrow_start_time = int(time.mktime(time.strptime(str(tomorrow), '%Y-%m-%d')))

# 明天结束时间戳
tomorrow_end_time = int(time.mktime(time.strptime(str(acquire), '%Y-%m-%d'))) - 1

# 本月开始时间戳
month_start_time = int(time.mktime(time.strptime(str(month_start_date), '%Y-%m-%d')))

# 本月结束时间戳
month_end_time = int(time.mktime(time.strptime(str(month_under_date), '%Y-%m-%d')))-1

# 上月开始时间戳
upper_month_start_time = ''

# 上月结束时间戳
upper_month_end_time = int(month_start_time)-1

